<?php
declare(strict_types=1);
namespace app\admin\service;

use app\api\service\CommonService;

class IndexService extends CommonService
{
    public function getIndexData(): array
    {
        $data = $this->getRobotData();
        $data['friend'] = $this->getFriend();
        $data['group'] = $this->getGroupCount();
        return successJson($data);
    }

    public function getRobotData(): array
    {
        $robot = (new RobotService())->getRobotList();
        $robotList['robot_count'] = count($robot['data']);
        $robotList['robot_start'] = 0;
        foreach ($robot['data'] as $v){
            if($v['status']==1){
                $robotList['robot_start']++;
            }
        }
        return $robotList;
    }

    public function getFriend(): int
    {
        $friend = (new RobotService())->wxChatFriend();
        return count($friend['data']);
    }

    public function getGroupCount(): int
    {
        $group = (new RobotService())->wxChatGroup();
        return count($group['data']);
    }





}